package cn.sangyy.car.doc;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.math.BigDecimal;
import java.util.Date;
@Data
@Document(indexName = "car",replicas = 1,shards = 5)
public class CarDoc {

    @Id
    private Long id;
    @Field(type = FieldType.Text, analyzer = "ik_max_word"
            , searchAnalyzer = "ik_max_word")
    private String title;
    @Field(type = FieldType.Keyword)
    private String cover;
    @Field(type = FieldType.Double)
    private BigDecimal saleprice; //原价
    @Field(type = FieldType.Double)
    private BigDecimal costprice; //售价
    @Field(type = FieldType.Integer)
    private Integer isnew; //是否新车
    @Field(type = FieldType.Date)
    @JsonFormat(pattern = "yyyy-MM-dd" ,timezone = "GMT+8")
    private Date registertime; //上牌时间
    @Field(type = FieldType.Double)
    private Double mileage; //里程
    @Field(type = FieldType.Long)
    private Long shopId; //店铺id
    @Field(type = FieldType.Text, analyzer = "ik_max_word"
            , searchAnalyzer = "ik_max_word")
    private String shopName; //店铺名称
    @Field(type = FieldType.Long)
    private Long sellerId;
    @Field(type = FieldType.Keyword)
    private String sellerName;
    @Field(type = FieldType.Keyword)
    private String shopAddress; //店铺地址
    @Field(type = FieldType.Date)
    private Date onsaletime; //上架时间
    @Field(type = FieldType.Integer)
    private Integer costeffective; //是否超值
    @Field(type = FieldType.Integer)
    private Integer rushsale; //急售
    @Field(type = FieldType.Integer)
    private Integer quasinewcar; //准新车
    @Field(type = FieldType.Integer)
    private Integer transitivecountry; //是否全国
    @Field(type = FieldType.Long)
    private Long typeId; //类型id
    @Field(type = FieldType.Long)
    private Long lastParentTypeId; //最高层父类型id
    @MultiField(
            mainField = @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart"),
            otherFields = {
                    @InnerField(suffix = "keyword", type = FieldType.Keyword)
            }
    )
    private String parentTypeName; //最高层父类型id
    @MultiField(
            mainField = @Field(type = FieldType.Text, analyzer = "ik_smart", searchAnalyzer = "ik_smart"),
            otherFields = {
                    @InnerField(suffix = "keyword", type = FieldType.Keyword)
            }
    )
    private String typeName; //类型名称
    @Field(type = FieldType.Text, analyzer = "ik_max_word"
            , searchAnalyzer = "ik_max_word")
    private String carInfo; //详细信息
}